<?xml version="1.0" encoding="UTF-8" ?>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib 	prefix="s" 			uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>근태관리 LOGIN</title>

	<script type="text/javascript">
		//로그인 버튼
		function fnc_login(f) {
			if (!fnc_validate(f)) {
				return false;
			}
			
			f.action = "loginTry.action";
			f.submit();
			
			return false;
		}
		
		function fnc_logout(f) {
			if (!confirm("<s:text name="alert.message.confirmLogout" />")) {
				return false;
			}
			
			f.action = "logout.action";
			f.submit();
			
		}
		
		//폼입력값 검사
		function fnc_validate(f) {
			var id		=	f.user_id.value;
			var pass	=	f.pass.value;
			
			if (id.replace(/^\s\s*/, '').replace(/\s\s*$/, '').length < 3 ) {
				alert("<s:text name="alert.message.invalidID" />");
				f.user_id.focus();
				return false;
			} else if (pass.replace(/^\s\s*/, '').replace(/\s\s*$/, '').length < 2) {
				alert("<s:text name="alert.message.invalidPassword" />");
				f.pass.focus();
				return false;
			} else {
				return true;
			}
		}

		function fnc_onload() {
			if ("<s:property value="msg" />".length > 0) {
				alert("<s:property value="msg" />");
			}
			document.frm.user_id.focus();
		}
	</script>
</head>
<body onload="fnc_onload()">
	<div>
	<s:form name="frm" id="frm" theme="simple" method="post" >
		<table>
			<tr>
				<td>ID</td>
				<td><s:textfield  name="user_id"/></td>
			</tr>
			<tr>
				<td>암호</td>
				<td><s:password  name="pass"/></td>
			</tr>
			<tr>
				<td colspan="2">
					<s:if test="%{#session['user'] == null}">
						<s:submit type="image" title="로그인" value="로그인" onclick="return fnc_login(this.form)"/>
					</s:if>
					<s:else>
						<s:submit type="image" title="로그아웃" value="로그아웃" onclick="return fnc_logout(this.form)" />
						<div>
							<s:select list="%{#session['empInfo']}" ></s:select>
						</div>
					</s:else>
				</td>
			</tr>
		</table>
	</s:form>
	</div>
</body>
</html>